package com.cskaoyan.servlet;

import com.cskaoyan.bean.Student;
import com.cskaoyan.bean.TestList;
import org.junit.BeforeClass;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
// loadOnStartup = 1 该servlet用于给TestList中的静态成员变量赋值（添加Student实例）
@WebServlet(value = "/demo1" ,loadOnStartup = 1)
public class testServlet1 extends HttpServlet {

    static {
        TestList.add2StudentList(new Student("zs",1,"1231123"));
    }

    // 如果访问testServlet1，则会打印  "first！！！"
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("first！！！");
        System.out.println();

    }
}

